package test.resolver;

import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Component;
import test.entity.User;
import test.mapper.UserMapper;

import javax.annotation.Resource;
import java.util.List;

/**
 * <br>
 *
 * @author 蒋カイセキ    Japan-Tokyo  18-11-8 下午6:30<br>
 * ブログ http://www.shoukaiseki.top/<br>
 * E-メール jiang28555@Gmail.com<br>
 **/
@Component
public class UserQuery implements GraphQLQueryResolver {

    @Resource
    private UserMapper userMapper;

    public User findUser(Integer id){
        return userMapper.getUser(id);
    }


    public List<User> list(Integer page,Integer size){
        if(page==null){
           page=1;
        }
        if(size==null){
            size=50;
        }
        PageHelper.startPage(page, size);
        return userMapper.getList(null);
    }
}
